KERNELFILE = kernel
BOOTFILES := boot/boot.o boot/main.o
SRCCFILES := $(shell find . -name "*.c" | grep -v main.c)
SRCSFILES := $(shell find . -name "*.s" | grep -v boot.s)
HDRFILES := $(shell find . -name "*.h")
OBJFILES := $(BOOTFILES) $(patsubst %.s,%.o, $(SRCSFILES)) $(patsubst %.c,%.o, $(SRCCFILES))


CCFLAGS = -nostdlib -nostdinc -fno-builtin -m32 -I./include
LDFLAGS = -T Link.ld
ASMFLAGS = -f elf



LDPATH = /usr/cross/bin/i386-elf-ld
CCPATH = /usr/cross/bin/i386-elf-gcc
ASMPATH = nasm

all: $(KERNELFILE)

clean:
	-@rm $(OBJFILES) $(KERNELFILE)
	
$(KERNELFILE): $(OBJFILES)
	@echo "  ln      " $(KERNELFILE)
	$(SOURCES)
	@$(LDPATH) $(LDFLAGS) -o $(KERNELFILE) $(OBJFILES)
	
%.o: %.s
	@echo "  nasm    " $<
	@$(ASMPATH) $(ASMFLAGS) $< -o $@
	
%.o: %.c
	@echo "  gcc     " $<
	@$(CCPATH) $(CCFLAGS) -c $< -o $@
